<template>
  <div v-loading="loading" style="min-height:50px">
    <h5ve-generate-form
      v-if="visible"
      ref="generateForm"
      :option="options"
      :value="formData"
      :dict="dict"
      :readonly="readonly"
      class="readonly"
    >
    </h5ve-generate-form>
  </div>
</template>

<script>
import {genByCode} from "@/api/toolkit/pageInfo";
import {mapGetters} from "vuex";

export default {
  data() {
    return {
      title: '',
      visible: false,
      loading: false,
      formData: {},
      options: {column: []}
    }
  },
  props: {
    readonly: {
      type: Boolean,
      default: true
    }
  },
  computed: {
    ...mapGetters([
      'dict'
    ])
  },
  methods: {
    createForm(code, id) {
      if (code && id) {
        this.loading = true
        this.visible = false
        this.formData = {}
        genByCode({code, id}).then(({msg, data}) => {
          this.options = JSON.parse(msg)
          console.log(this.options)
          this.formData = data
          this.loading = false
          this.visible = true
        }).catch(() => {
          this.loading = false
          this.visible = true
        })
      } else {
        this.$message.info('没有关联流程表单!')
        this.visible = true
      }
    }
  }
}
</script>
